@extends('admin.layouts.app')

@section('title')
    课程管理
@endsection

<!-- 侧边栏 -->
@section('sidebar')
    @include('admin.course.menu')
@endsection

<!--  -->
@section('content')
    <!-- 直接使用组件名即可，定义好的变量可以通过类似html属性的方式传递 -->
    <x-page_title title="课程管理" comment="课程管理中心"></x-page_title>
    <div class='row'>
        <div class='col-12'>
            <table class="table table-sm">
                <thead class="thead-light">
                    <tr>
                        <th scope="col">id</th>
                        <th scope="col" width='240'>头图</th>
                        <th scope="col">课程</th>
                        <th scope="col">排序</th>
                        <th scope="col">创建时间</th>
                        <th scope="col">编辑时间</th>
                        <th scope="col">管理</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($courses as $course)
                        <tr>
                            <th scope="row" style="vertical-align: middle;">{{$course->id}}</th>
                            <td style="vertical-align: middle;">
                                <img src='{{$course->image_link}}' class='img-fluid' style='height: 84px; width: auto;' />
                            </td>
                            <td style="vertical-align: middle;">{{$course->title}}</td>
                            <td style="vertical-align: middle;">{{$course->sort}}</td>
                            <td style="vertical-align: middle;">{{$course->created_at}}</td>
                            <td style="vertical-align: middle;">{{$course->updated_at}}</td>
                            <td style="vertical-align: middle;">
                                <a href='{{route("admin.course.detail", [$course->id])}}' class='btn btn-sm btn-primary'>管理</a>
                                <a href='{{route("admin.course.add", [$course->id])}}' class='btn btn-sm btn-secondary'>修改</a>
                                <a onclick='return confirm("确认删除吗？")' href='{{route("admin.course.remove", [$course->id])}}'
                                    class='btn btn-sm btn-danger'>移除</a>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </div>
@endsection